{% extends "restricted/base.html" %}
{% load js %}
{% load nm %}

{% block head_resources %}
{{block.super}}
{% jsinclude "tables" %}
<style type="text/css">
table.proctable {
  font-size: small;
}
table.proctable tbody {
  white-space: nowrap;
}
</style>
{% endblock %}

{% block head %}
{{block.super}}
<script type="text/javascript">
$(function() {
    $(".proctable").tablesorter({
        textExtraction: function(node) {
            val = node.getAttribute("val");
            if (val == null)
                val = node.textContent || node.innerText;
            return val;
        },
    })
});
</script>
{% endblock %}

{% block breadcrumbs %}{{block.super}} / <a href="{% url 'restricted_ammain' %}">ammain</a>{% endblock %}

{% block relatedpages %}
<a href="{% url 'restricted_amprofile' visitor.lookup_key %}">am settings</a>
{{block.super}}
{% endblock %}

{% block content %}

<h1>Debian New Member</h1>

<p>Currently the database thinks you have the following functions:</p>
<ul>
    {% if visitor.am.is_am_ctte %}<li>New Member Committee</li>{% endif %}
    {% if visitor.am.is_am %}<li>Application Manager with {{ visitor.am.slots }} slots</li>{% endif %}
    {% if visitor.am.is_fd %}<li>Front Desk</li>{% endif %}
    {% if visitor.am.is_dam %}<li>Debian Account Manager</li>{% endif %}
</ul>

{% if visitor.is_admin %}

<h2>Front desk</h2>

<h3>Processes needing attention</h3>

{% include "process/process_list.html" with procs=current_processes %}

{% if approved_processes %}
<h3>Processes approved but not yet closed</h3>

{% include "process/process_list.html" with procs=approved_processes %}
{% endif %}

<h3>Application manager availability</h3>

{% if am_available %}

<p>The following managers have free slots (#free/#slots):</p>
<ul class="horizontal">
    {% for a in am_available %}
    <li><a href="{% url 'restricted_amprofile' key=a.person.lookup_key %}">{{a.person.uid}}</a>
        ({{a.stats_free}}/{{a.slots}})</li>
    {% endfor %}
</ul>
{% else %}
<p>Currently there are no free application managers.</p>
{% endif %}

<h3>Old style processes</h3>

<p>The following people have applied but have not enough advocates or we did not send the activity poll yet.</p>
{% include "restricted/process_table.html" with p=p progs=prog_app_new extras="" only %}

<p>The following people have not replied to the activity poll yet.</p>
{% include "restricted/process_table.html" with p=p progs=prog_poll_sent extras="" only %}

<p>The following applicants are waiting for an Application Manager to be
assigned (first one is oldest).</p>
{% include "restricted/process_table.html" with p=p progs=prog_app_ok extras="" only %}

<p>Applicants currently not ready to be assigned to an AM (ordered by hold date):</p>
{% include "restricted/process_table.html" with p=p progs=prog_app_hold extras="" only %}

<p>Applicants assigned to AM but AM has not confirmed:</p>
{% include "restricted/process_table.html" with p=p progs=prog_am_rcvd extras="m" only %}

<p>The reports of the following applicants approved by their AM need to be
checked:</p>
{% include "restricted/process_table.html" with p=p progs=prog_am_ok extras="m" only %}

<p>The following applicants have incomplete AM reports (ordered by hold date):</p>
{% include "restricted/process_table.html" with p=p progs=prog_fd_hold extras="m" only %}


<h2>Debian Account Manager</h2>

<p>The following applicants have been approved by the NM committee and the FD
but a DAM has not fully processed them yet (sorted by FD approval):</p>
{% include "restricted/process_table.html" with p=p progs=prog_fd_ok extras="m" only %}

<p>Applicants approved by a DAM, but for which no account has been created yet:</p>
{% include "restricted/process_table.html" with p=p progs=prog_dam_ok extras="m" only %}

<p>These are applications that have been put on hold at the DAM stage
(sorted by hold date):</p>
{% include "restricted/process_table.html" with p=p progs=prog_dam_hold extras="m" only %}

{% endif %}


{# only show application manager section if the current user either has AM slots or any existing process assigned #}
{% if visitor.am.slots or am_prog_rcvd or am_prog_am or am_prog_hold or am_prog_done %}
<h2>Application Manager</h2>

<p>Hello <b>{{visitor.uid}}</b>, here is a list of New Member applicants that
you are the AM for:</p>

{% include "process/process_list.html" with procs=am_processes %}

<h3>Applicants to Accept</h3>

<p>These applicants have been assigned to you by the Front Desk but you have
not confirmed that you will or will not be their AM (ordered by assignment
date).</p>
{% include "restricted/process_table.html" with p=p progs=am_prog_rcvd extras="" only %}

<h3>Applicants to process</h3>

<p>The following applicants you are the AM for (ordered by the date you
accepted them as NMs):</p>
{% include "restricted/process_table.html" with p=p progs=am_prog_am extras="" only %}

<h3>Applicants on Hold</h3>

<p>Applicants who make it here have some issue with completing the process but
are expected to be able to work around that soon (ordered by hold date).</p>
{% include "restricted/process_table.html" with p=p progs=am_prog_hold extras="" only %}

<h3>Processed Applicants</h3>

<p>These applicants you have processed through the system and are here for
historical or informational purposes (ordered by account creation date).</p>
{% include "restricted/process_table.html" with p=p progs=am_prog_done extras="" only %}
{% endif %}

{% comment %}
                      <H2>Key</H2>
                      <UL>
                          <LI><IMG src="images/shake.png" alt="V" width="16" height="16"> : Advocate Check ok
                          <LI><IMG src="images/mag.png" alt="I" width="16" height="16"> : Identification complete
                          <LI><IMG src="images/dfsg.png" alt="P" width="16" height="16"> : Philosophy and Procedures complete
                          <LI><IMG src="images/hammer.png" alt="T" width="16" height="16"> : Tasks and Skills complete
                          <LI><IMG src="images/thumb.png" alt="A" width="16" height="16"> : Application Manager Recommends applicant
                          <LI><IMG src="images/new.png" alt="N" width="16" height="16"> : New Debian developer
                          <LI><IMG src="images/hold.png" alt="H" width="16" height="16"> : On hold
                      </UL>
                  </div> <!-- end maincol -->

{% endcomment %}

{% endblock %}

